// ===========================================================
// Truncate:  Miscellaneous truncation and normalizing
// operations.
// ============================================================

`timescale 1ns/1ns

module Truncate;
  
  integer    Int;
  reg[007:0] Byte = 'b0;
  reg[031:0] Word = 'b0;
  reg[063:0] Long = 'b0;
  reg[127:0] Dlong= 'b0;
  
  initial
    begin
    Int = 'b0; // Can't initialize in declaration.
    #20
         Int = 6'd1; $display("at %0t: Int=32'h%h",$time, Int); 
        Byte = 6'd1; $display("at %0t: Byte=32'h%h",$time, Byte); 
        Word = 6'd1; $display("at %0t: Word=32'h%h",$time, Word); 
        Long = 6'd1; $display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = 6'd1; $display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    #20
         Int = -6'd1;$display("at %0t: Int=32'h%h",$time, Int); 
        Byte = -6'd1;$display("at %0t: Byte=32'h%h",$time, Byte); 
        Word = -6'd1;$display("at %0t: Word=32'h%h",$time, Word); 
        Long = -6'd1;$display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = -6'd1;$display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    #20
         Int = 36'd1;$display("at %0t: Int=32'h%h",$time, Int); 
        Byte = 36'd1;$display("at %0t: Byte=32'h%h",$time, Byte); 
        Word = 36'd1;$display("at %0t: Word=32'h%h",$time, Word); 
        Long = 36'd1;$display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = 36'd1;$display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    #20
         Int = -36'd1;$display("at %0t: Int=32'h%h",$time, Int); 
        Byte = -36'd1;$display("at %0t: Byte=32'h%h",$time, Byte); 
        Word = -36'd1;$display("at %0t: Word=32'h%h",$time, Word); 
        Long = -36'd1;$display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = -36'd1;$display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    Int = 1;
    #20
        Byte = Int;$display("at %0t: Byte=32'h%h",$time, Byte); 
        Word = Int;$display("at %0t: Word=32'h%h",$time, Word); 
        Long = Int;$display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = Int;$display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    Int = -1;
    #20
        Byte = Int;$display("at %0t: Byte=32'h%h",$time, Byte); 
        Word = Int;$display("at %0t: Word=32'h%h",$time, Word); 
        Long = Int;$display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = Int;$display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    Word = 32'h7eee_777f;
    #20
        Byte = Word;$display("at %0t: Byte=32'h%h",$time, Byte); 
         Int = Word;$display("at %0t: Word=32'h%h",$time, Word); 
        Long = Word;$display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = Word;$display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    Word = 32'hf777_eee7;
    #20
        Byte = Word;$display("at %0t: Byte=32'h%h",$time, Byte); 
         Int = Word;$display("at %0t: Word=32'h%h",$time, Word); 
        Long = Word;$display("at %0t: Long=32'h%h",$time, Long); 
       Dlong = Word;$display("at %0t: Dlong=32'h%h",$time, Dlong); 
    
    #20 $finish;
    end
  
endmodule // Truncate.
